{extend name="user/index" /}

{block name="title"}
<title>[ 隐藏管理界面 ]</title>
{/block}

{block name="css"}
{css href="_CSS_user.css"}
{/block}

{block name="main"}
<div class="container mt50 text-success">
    <h1>总入口密码设定</h1>
    <div class="col-md-8">
        <form action="{:url('index/user/resetpass')}" method="post">
            <div class="input-group">
                <input class="form-control input-lg" style="font-size: 25px" type="text" name="pass"
                       placeholder="设置总入口密码，此密码直接覆盖原密码" maxlength="32">
                <span class="input-group-btn">
                <button class="btn btn-lg btn-danger" type="submit">立即修改</button>
            </span>
            </div>
        </form>
    </div>
    <div class="col-md-4">
        <div class="btn-group pull-right">
            <a href="{:url('index/user/createadmin')}" class="btn btn-info">新增管理员</a>
        </div>
    </div>
</div>

<hr>

<div class="container text-success">
    <div class="collapse" id="pass">
        <div class="bg-info with-padding p30">
            <form action="{:url('index/user/adminpass')}" method="post" name="adminpass" onsubmit="return checkePass()">
                <input type="hidden" name="id" id="adminid">
                <div class="input-group col-md-10">
                    <input class="form-control input-lg" style="font-size: 25px" type="text" name="pass"
                           placeholder="管理员密码会立即生效，密码不得为空！">
                    <span class="input-group-btn">
                        <button class="btn btn-lg btn-primary" type="submit">立即修改</button>
                    </span>
                </div>
            </form>
        </div>
    </div>
    <hr>
    <h1>管理员管理</h1>
    <table class="table table-hover table-bordered table-auto" style="font-size: 20px">
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Pwd</th>
            <th>Level</th>
            <th>Edit</th>
        </tr>
        {foreach $adminuser as $v}
        <tr>
            <td>{$v['id']}</td>
            <td>{$v['name']}</td>
            <td>{$v['pwd']}</td>
            <td>{$v['level']}</td>
            <td>
                <button class="btn btn-info passBtn" data-id="{$v['id']}" data-toggle="collapse" data-target="#pass">
                    改密码
                </button>
                <button class="btn editBtn">编辑</button>
                <button class="btn  btn-danger delBtn">删除</button>
            </td>
        </tr>
        {/foreach}
    </table>
</div>
{/block}

{block name="js"}
<script>
    $('.passBtn').on('click', function () {
        let id = $(this).attr('data-id');
        $('#adminid').val(id);
    });

    function checkePass() {
        if (document.adminpass.pass.value == '') {
            return false;
        }
    }

</script>
{/block}
